//
//  FirstCollectionViewCell.m
//  Travel_M_Travel
//
//  Created by dlios on 15-3-25.
//  Copyright (c) 2015年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "FirstCollectionViewCell.h"
#import "UIImageView+WebCache.h"
#import "AMBlurView.h"
#import "UIColor+AddColor.h"
@implementation FirstCollectionViewCell
- (void)dealloc
{
    [_cover_path release];
    [_tname release];
    [_background release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
//        self.background = [[UIImageView alloc] initWithFrame:self.contentView.bounds];
//        _background.image = [UIImage imageNamed:@"background.jpeg"];
//        _background.userInteractionEnabled = YES;
//        _background.layer.cornerRadius = 8;
//        _background.layer.masksToBounds = true;
//        [self.contentView addSubview:_background];
//        [_background release];
    
//        self.abv = [[AMBlurView alloc] initWithFrame:self.contentView.bounds];
//        _abv.userInteractionEnabled = NO;
//        _abv.alpha = 0.2;
//        [self.background addSubview:_abv];
//        [_abv release];
        
        self.cover_path = [[UIImageView alloc] init];
        self.cover_path.backgroundColor = [UIColor yellowColor];
        self.cover_path.layer.cornerRadius = 5;
        self.cover_path.clipsToBounds = YES;
        [self.contentView addSubview:_cover_path];
        [_cover_path release];
        
        self.tname = [[UILabel alloc] init];
        self.tname.font = [UIFont fontWithName:@"AmericanTypewriter" size:14];
        self.tname.textAlignment = 1;
       [self.contentView addSubview:_tname];
        [_tname release];
        
        
    }
    return self;
}

- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes
{
    
//    self.backgroundColor = [UIColor blackColor];
    
    self.cover_path.frame = CGRectMake(2, 2, self.contentView.frame.size.width - 4, self.contentView.frame.size.height*4/5 - 2);
    
    
    self.tname.frame = CGRectMake(10, self.contentView.frame.size.height*4/5, self.contentView.frame.size.width - 20, self.contentView.frame.size.height/5);
    self.tname.textColor = [UIColor colorFromHexCode:@"121a2a"];
    

}

- (void)setMds:(MusicDataSource *)mds
{
    if (_mds != mds) {
        [_mds release];
        _mds = [mds retain];
    }
    
    NSString *str = self.mds.cover_path;
    
    str = [str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    NSURL *url = [NSURL URLWithString:str];
    [self.cover_path setImageWithURL:url];
    self.tname.text = self.mds.tname;


}
@end
